package io.renren.modules.store.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.store.dao.TStoreAccountUnitDao;
import io.renren.modules.store.entity.TStoreAccountUnitEntity;
import io.renren.modules.store.service.TStoreAccountUnitService;


@Service("tStoreAccountUnitService")
public class TStoreAccountUnitServiceImpl extends ServiceImpl<TStoreAccountUnitDao, TStoreAccountUnitEntity> implements TStoreAccountUnitService {

    @Autowired
    private TStoreAccountUnitDao accountUnitDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TStoreAccountUnitEntity> page = this.page(
                new Query<TStoreAccountUnitEntity>().getPage(params),
                new QueryWrapper<TStoreAccountUnitEntity>()
                        .eq(!params.get("sellerId").equals(""),"seller_id",params.get("sellerId"))
                        .eq(!params.get("key").equals(""),"account_unit_tel",params.get("key"))
                        .or()
                        .eq(!params.get("key").equals(""),"tel",params.get("key"))
                        .or()
                        .like(!params.get("key").equals(""),"account_unit_name",params.get("key"))
        );

        return new PageUtils(page);
    }

    @Override
    public void updateAccount(Map<String, Object> map) {
        accountUnitDao.updateAccount(map);
    }

}